<%@ page import="cn.milk.dao.TaskDAO" %>
<%@ page import="cn.milk.model.Task" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>编辑任务</title>
    <style>
        body {
            font-family: "Arial", sans-serif;
            margin: 0;
            padding: 0;
            background: url('background.jpg') no-repeat center center fixed;
            background-size: cover;
            color: #fff;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
        }

        .container {
            display: flex;
            width: 800px;
            background: rgba(0, 0, 0, 0.7);
            border-radius: 10px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
            overflow: hidden;
        }

        .left-panel {
            flex: 1;
            background: #ff6f61;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            color: #fff;
            padding: 20px;
            font-size: 18px;
            font-weight: bold;
        }

        .left-panel h1 {
            margin: 0;
            font-size: 24px;
        }

        .right-panel {
            flex: 2;
            padding: 30px;
        }

        label {
            display: block;
            font-weight: bold;
            margin-bottom: 5px;
            color: #ddd;
        }

        input[type="number"],
        input[type="text"],
        select {
            width: 100%;
            padding: 10px;
            margin-bottom: 20px;
            border: 1px solid #ced4da;
            border-radius: 5px;
            font-size: 16px;
            color: #495057;
        }

        input:focus,
        select:focus {
            border-color: #ff6f61;
            outline: none;
            box-shadow: 0 0 5px rgba(255, 111, 97, 0.5);
        }

        button {
            background-color: #ff6f61;
            color: #ffffff;
            border: none;
            border-radius: 5px;
            padding: 10px 20px;
            font-size: 16px;
            cursor: pointer;
            margin: 0 10px;
        }

        button:hover {
            background-color: #ff5a4d;
        }

        a {
            text-decoration: none;
            color: #ff6f61;
            font-size: 14px;
        }

        a:hover {
            color: #ff5a4d;
            text-decoration: underline;
        }

        .button-group {
            text-align: center;
        }
    </style>
</head>
<body>
<%
    TaskDAO taskDAO = new TaskDAO();
    Task task = taskDAO.getTaskById(Integer.parseInt(request.getParameter("id")));
    request.setAttribute("task", task);
%>

<div class="container">
    <div class="left-panel">
        <h1>编辑任务</h1>
        <p>修改订单任务信息</p>
    </div>
    <div class="right-panel">
        <form method="post" action="TaskServlet">
            <input type="hidden" name="action" value="edit" />
            <input type="hidden" name="id" value="${task.id}" />

            <label for="ordersid">订单ID：</label>
            <input type="number" id="ordersid" name="ordersid" value="${task.ordersid}" required />

            <label for="menuname">菜品名称：</label>
            <input type="text" id="menuname" name="menuname" value="${task.menuname}" required />

            <label for="quantity">数量：</label>
            <input type="number" id="quantity" name="quantity" value="${task.quantity}" min="1" required />

            <label for="status">状态：</label>
            <select id="status" name="status">
                <option value="1" <%= task.getStatus() == 1 ? "selected" : "" %>>待做</option>
                <option value="2" <%= task.getStatus() == 2 ? "selected" : "" %>>已做</option>
            </select>

            <div class="button-group">
                <button type="submit">保存</button>
                <a href="TaskServlet">返回</a>
            </div>
        </form>
    </div>
</div>
</body>
</html>
